package wyj;

import java.util.Scanner;

class Main3 {
    public static void main(String[] args){
        int i,x,y,z,q,sum,c;
        Scanner in = new Scanner(System.in);
        i = in.nextInt();
        x=1;
        z=0;
        q=1;
        sum=0;
        c=1;
        while(i>0&i<=1000000){
            y = i%10;
            if (y%2==x%2){
                z=1;
            }
            else {
                z=0;
            }
            sum=sum+z*c;
            c=c*2;
            x++;
            i=i/10;


        }
        System.out.println(sum);
    }
}
